//
//  CoverViewController.m
//  Anyair
//
//  Created by karlcool on 14-5-12.
//  Copyright (c) 2014年 Karlcool. All rights reserved.
//

#import "CoverViewController.h"
#import "LogInViewController.h"
#import "SignInViewController.h"
#import "MainViewController.h"

@interface CoverViewController ()

@end

@implementation CoverViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    if (!IPHONE_5) {
        self.browseBtn.frame = CGRectMake(self.browseBtn.frame.origin.x, 380, self.browseBtn.frame.size.width, self.browseBtn.frame.size.height);
        self.LogInBtn.frame = CGRectMake(self.LogInBtn.frame.origin.x, 380, self.LogInBtn.frame.size.width, self.LogInBtn.frame.size.height);
        self.SignInBtn.frame = CGRectMake(self.SignInBtn.frame.origin.x, 380, self.SignInBtn.frame.size.width, self.SignInBtn.frame.size.height);
        self.coverImageView.image = [UIImage imageNamed:@"Load"];
    } else {
        self.coverImageView.image = [UIImage imageNamed:@"Load5"];
    }
    
    //检查登录状态
    [LRUserManager createManager].isLogIn = [[NSUserDefaults standardUserDefaults]boolForKey:@"isLogIn"];
    if ([LRUserManager createManager].isLogIn) {
        self.browseBtn.alpha = 0;
        self.SignInBtn.alpha = 0;
        self.LogInBtn.alpha = 0;
        [self performSelector:@selector(enterBrowse:) withObject:nil afterDelay:2];
    }
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(logInSuccess) name:@"logInSuccess" object:nil];
 
    
    
    
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)enterBrowse:(UIButton *)sender {
    
    MainViewController *main = [[MainViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:main];
    navi.navigationBarHidden = YES;
    [self presentViewController:navi animated:YES completion:^{
        ;
    }];
    
}

- (void)logInSuccess {
    
    MainViewController *main = [[MainViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:main];
    navi.navigationBarHidden = YES;
    [self presentViewController:navi animated:NO completion:^{
        ;
    }];
    
}

- (IBAction)enterLogIn:(UIButton *)sender {
    
    LogInViewController *logIn = [[LogInViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:logIn];
    navi.navigationBarHidden = YES;
    [self presentViewController:navi animated:YES completion:^{
        ;
    }];
}

- (IBAction)enterSignIn:(UIButton *)sender {
    SignInViewController *signIn = [[SignInViewController alloc]init];
    [self presentViewController:signIn animated:YES completion:^{
        ;
    }];
}
@end
